package com.mrzhou.common.launch;

import com.mrzhou.common.constant.LaunchConstant;
import com.mrzhou.core.tool.launch.LaunchService;
import org.springframework.boot.builder.SpringApplicationBuilder;

import java.util.Properties;

/**
 * @author qiang.zhou
 */
public class CloudLaunchServiceImpl implements LaunchService {
    @Override
    public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) {
        Properties prop = System.getProperties();
        // 开启nacos自动刷新配置的功能
        prop.setProperty("spring.cloud.nacos.config.refresh.enabled", "true");
        prop.setProperty("spring.cloud.nacos.discovery.server-addr", LaunchConstant.nacosAdd(profile));
        prop.setProperty("spring.cloud.nacos.config.server-addr", LaunchConstant.nacosAdd(profile));
        prop.setProperty("spring.cloud.sentinel.transport.dashboard", LaunchConstant.sentinelAddress(profile));
        // 配置解密密钥
        prop.setProperty("jasypt.encryptor.password", "mrzhou-cloud");
    }

}
